package com.wg.springboot.web;

import com.wg.spring.feign.Envir;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

//@Controller
@RestController
@Slf4j
//@Primary
public class IndexController {
    @Resource
    private Envir envir;

    @RequestMapping(value = "spring/say1")
    public @ResponseBody String say2() {
//        @ResponseBody表示返回JSON  之前MVC框架String返回的是页面
        String say = envir.say();
        log.info(say);
        return "hello spingboot";
    }

    //    @RequestMapping(value = "/say")
    @ResponseBody//map能转成JSON
    public Map<String, Object> mapValue() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("springboot", "test");
        return map;
    }
}
